package com.qfedu.mtl.util.page;

import java.util.List;

/**
 * 这个类用于描述一个分页结果，万事万物结尾对象。
 */
public class Pager<T> {
    //要显示的数据
    private List<T> rows;
    //当前页码
    private Integer pageNum;
    //每页大小
    private Integer pageSize;
    //总条数
    private Integer total;
    //总页数
    private Integer pages;
    public Pager(List<T> rows, Integer pageNum, Integer pageSize, Integer total) {
        this.rows = rows;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.total = total;
        //计算总页数
        this.pages =this.total%this.pageSize==0?this.total/this.pageSize:(this.total/this.pageSize)+1;
    }
    public List<T> getRows() {
        return rows;
    }
    public void setRows(List<T> rows) {
        this.rows = rows;
    }
    public Integer getPageNum() {
        return pageNum;
    }
    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }
    public Integer getPageSize() {
        return pageSize;
    }
    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }
    public Integer getTotal() {
        return total;
    }
    public void setTotal(Integer total) {
        this.total = total;
    }
    public Integer getPages() {
        return pages;
    }
    public void setPages(Integer pages) {
        this.pages = pages;
    }
    @Override
    public String toString() {
        return "Pager{" +
                "rows=" + rows +
                ", pageNum=" + pageNum +
                ", pageSize=" + pageSize +
                ", total=" + total +
                ", pages=" + pages +
                '}';
    }
}
